package com.zhb.blog.dao;

import com.zhb.blog.model.Comment;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentRepository extends JpaRepository<Comment,Long> {


    List<Comment> findByBlogIdAndParentCommentIsNull(Long id, Sort sort);

    @Query(value = "delete from t_comment where blog_id =(:id)",nativeQuery = true)
    int deleteByBlogId(@Param("id") Long id);
}
